/*
 *  Copyright (C) 2010 {Apertum}Projects. web: www.apertum.ru email: info@apertum.ru
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ru.apertum.qsystem.client.forms;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.dom4j.Element;
import org.dom4j.Node;
import org.jdesktop.application.Application;
import org.jdesktop.application.ResourceMap;
import ru.apertum.qsystem.QSystem;
import ru.apertum.qsystem.common.Uses;import ru.apertum.qsystem.common.QLog;

/**
 * Created on 14 Апрель 2009 г., 18:01
 * @author Evgeniy Egorov
 */
public class FBoardParams extends javax.swing.JDialog {

    private static ResourceMap localeMap = null;

    private static String getLocaleMessage(String key) {
        if (localeMap == null) {
            localeMap = Application.getInstance(QSystem.class).getContext().getResourceMap(FBoardParams.class);
        }
        return localeMap.getString(key);
    }
    /**
     * Результат
     */
    private static boolean ok;
    /**
     * Используемая ссылка на диалоговое окно.
     */
    private static FBoardParams boardParams;

    /** Creates new form FBoardParams
     * @param parent относительно чего модальна форма
     * @param modal модальна или нет
     */
    public FBoardParams(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        buttonOk.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                ok = true;
                // изменить переданые параметры
                saveXML();
                setVisible(false);
            }
        });
        buttonCancel.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                ok = false;
                setVisible(false);
            }
        });

        spinnerFontSize.getModel().addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                final Font fnt = new Font(runningLabel.getFont().getName(), runningLabel.getFont().getStyle(), (Integer) spinnerFontSize.getValue());
                runningLabel.setFont(fnt);
            }
        });
        textFieldFontColor.addKeyListener(new KeyListener() {

            @Override
            public void keyTyped(KeyEvent e) {
                runningLabel.setForeground(Color.decode("#" + textFieldFontColor.getText()));
            }

            @Override
            public void keyPressed(KeyEvent e) {
                //runningLabel.setForeground(Color.decode(textFieldFontColor.getText()));
            }

            @Override
            public void keyReleased(KeyEvent e) {
                //runningLabel.setForeground(Color.decode(textFieldFontColor.getText()));
            }
        });
        spinnerSpeed.getModel().addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                runningLabel.setSpeedRunningText((Integer) spinnerSpeed.getValue());
            }
        });
    }

    /**
     * Выбор параметров для части общего табло.
     * @param owner относительно этого контрола модальность и позиционирование
     * @param params
     * @param caption
     */
    public static void changeParams(JFrame owner, Element params, String caption) {
        if (boardParams == null) {
            boardParams = new FBoardParams(owner, true);
        }
        Uses.setLocation(boardParams);
        boardParams.loadXML(params);
        boardParams.setTitle(caption);
        boardParams.setVisible(true);
    }
    /**
     * Ветка XML-параметров
     */
    private Element params = null;

    /**
     * Загрузка параметров из XML ветки
     * @param params из нее грузим параметры
     * <Left visible="0" Размер="20">
     *    <Параметер Наименование="Бегущий текст" Тип="3" Значение=""/>
     *    <Параметер Наименование="Скорость бегущего текста" Тип="1" Значение="4"/>
     *    <Параметер Наименование="Размер шрифта" Тип="1" Значение="50"/>
     *    <Параметер Наименование="Цвет шрифта" Тип="1" Значение="222"/>
     *    <Параметер Наименование="Простая дата" Тип="4" Значение="0"/>
     *    <Параметер Наименование="Фоновое изображение" Тип="3" Значение="config/mainboard/1u.PNG"/>
     *    <Параметер Наименование="Видеофайл" Тип="3" Значение="D:/WORK/QSystem/config/mainboard/sezd17.mpg"/>
     * </Left>
     */
    private void loadXML(Element params) {
        textFieldRunning.setText(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_RUNNING_TEXT).get(0).attributeValue(Uses.TAG_BOARD_VALUE));
        textAreaHtml.setText(params.getText().trim());
        runningLabel.setRunningText(textFieldRunning.getText());
        runningLabel.setText(textAreaHtml.getText().trim());
        textFieldPict.setText(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FON_IMG).get(0).attributeValue(Uses.TAG_BOARD_VALUE));
        textFieldVideo.setText(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_VIDEO_FILE).get(0).attributeValue(Uses.TAG_BOARD_VALUE));
        spinnerFontSize.setValue(Integer.parseInt(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FONT_SIZE).get(0).attributeValue(Uses.TAG_BOARD_VALUE)));
        textFieldFontColor.setText(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FONT_COLOR).get(0).attributeValue(Uses.TAG_BOARD_VALUE));
        runningLabel.setFont(new Font(runningLabel.getFont().getFontName(), runningLabel.getFont().getStyle(), (Integer) spinnerFontSize.getValue()));
        runningLabel.setForeground(Color.decode("#" + textFieldFontColor.getText()));
        spinnerSpeed.setValue(Integer.parseInt(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_SPEED_TEXT).get(0).attributeValue(Uses.TAG_BOARD_VALUE)));
        runningLabel.setSpeedRunningText((Integer) spinnerSpeed.getValue());
        checkBoxDate.setSelected("1".equals(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_SIMPLE_DATE).get(0).attributeValue(Uses.TAG_BOARD_VALUE)));
        runningLabel.setShowTime(checkBoxDate.isSelected());
        this.params = params;
    }

    /**
     * Сохраним измененные параметры в XML
     */
    private void saveXML() {
        if (params != null) {
            Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_RUNNING_TEXT).get(0).addAttribute(Uses.TAG_BOARD_VALUE, textFieldRunning.getText());
            Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FON_IMG).get(0).addAttribute(Uses.TAG_BOARD_VALUE, textFieldPict.getText());
            // удалить предыдущие узды CDATA
            for (int i = 0; i < params.nodeCount(); i++) {
                final Node node = params.node(i);
                if (node.getNodeType() == Node.CDATA_SECTION_NODE) {
                    params.remove(node);
                }
            }
            final String str = textAreaHtml.getText();
            if (!"".equals(str)) {
                params.addCDATA(str);
            }
            Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_VIDEO_FILE).get(0).addAttribute(Uses.TAG_BOARD_VALUE, textFieldVideo.getText());
            Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FONT_SIZE).get(0).addAttribute(Uses.TAG_BOARD_VALUE, String.valueOf((Integer) spinnerFontSize.getValue()));
            Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_SPEED_TEXT).get(0).addAttribute(Uses.TAG_BOARD_VALUE, String.valueOf((Integer) spinnerSpeed.getValue()));
            Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FONT_COLOR).get(0).addAttribute(Uses.TAG_BOARD_VALUE, textFieldFontColor.getText());
            Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_SIMPLE_DATE).get(0).addAttribute(Uses.TAG_BOARD_VALUE, checkBoxDate.isSelected() ? "1" : "0");

        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonOk = new javax.swing.JButton();
        buttonCancel = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        textFieldRunning = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        spinnerSpeed = new javax.swing.JSpinner();
        jLabel5 = new javax.swing.JLabel();
        textFieldPict = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        textFieldVideo = new javax.swing.JTextField();
        checkBoxDate = new javax.swing.JCheckBox();
        jLabel7 = new javax.swing.JLabel();
        spinnerFontSize = new javax.swing.JSpinner();
        buttonRun = new javax.swing.JToggleButton();
        jLabel8 = new javax.swing.JLabel();
        buttonColor = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        textAreaHtml = new javax.swing.JTextArea();
        textFieldFontColor = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        runningLabel = new ru.apertum.qsystem.common.RunningLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ru.apertum.qsystem.QSystem.class).getContext().getResourceMap(FBoardParams.class);
        buttonOk.setText(resourceMap.getString("buttonOk.text")); // NOI18N
        buttonOk.setName("buttonOk"); // NOI18N

        buttonCancel.setText(resourceMap.getString("buttonCancel.text")); // NOI18N
        buttonCancel.setName("buttonCancel"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        textFieldRunning.setText(resourceMap.getString("textFieldRunning.text")); // NOI18N
        textFieldRunning.setName("textFieldRunning"); // NOI18N
        textFieldRunning.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textFieldRunningKeyReleased(evt);
            }
        });

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        spinnerSpeed.setName("spinnerSpeed"); // NOI18N
        spinnerSpeed.setValue(10);

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        textFieldPict.setText(resourceMap.getString("textFieldPict.text")); // NOI18N
        textFieldPict.setName("textFieldPict"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        textFieldVideo.setText(resourceMap.getString("textFieldVideo.text")); // NOI18N
        textFieldVideo.setName("textFieldVideo"); // NOI18N

        checkBoxDate.setText(resourceMap.getString("checkBoxDate.text")); // NOI18N
        checkBoxDate.setName("checkBoxDate"); // NOI18N
        checkBoxDate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkBoxDateActionPerformed(evt);
            }
        });

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        spinnerFontSize.setName("spinnerFontSize"); // NOI18N
        spinnerFontSize.setValue(20);

        buttonRun.setText(resourceMap.getString("buttonRun.text")); // NOI18N
        buttonRun.setName("buttonRun"); // NOI18N
        buttonRun.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonRunActionPerformed(evt);
            }
        });

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        buttonColor.setText(resourceMap.getString("buttonColor.text")); // NOI18N
        buttonColor.setName("buttonColor"); // NOI18N
        buttonColor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonColorActionPerformed(evt);
            }
        });

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        textAreaHtml.setColumns(20);
        textAreaHtml.setLineWrap(true);
        textAreaHtml.setRows(5);
        textAreaHtml.setWrapStyleWord(true);
        textAreaHtml.setName("textAreaHtml"); // NOI18N
        textAreaHtml.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textAreaHtmlKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(textAreaHtml);

        textFieldFontColor.setText(resourceMap.getString("textFieldFontColor.text")); // NOI18N
        textFieldFontColor.setName("textFieldFontColor"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        runningLabel.setBackground(resourceMap.getColor("runningLabel.background")); // NOI18N
        runningLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        runningLabel.setText(resourceMap.getString("runningLabel.text")); // NOI18N
        runningLabel.setName("runningLabel"); // NOI18N
        jScrollPane2.setViewportView(runningLabel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 654, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(buttonOk)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textFieldRunning, javax.swing.GroupLayout.DEFAULT_SIZE, 574, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(spinnerFontSize, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(spinnerSpeed, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(textFieldFontColor, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(buttonColor))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(checkBoxDate)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 338, Short.MAX_VALUE)
                                        .addComponent(buttonRun))))))
                    .addComponent(jLabel7)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(31, 31, 31)
                        .addComponent(textFieldPict, javax.swing.GroupLayout.DEFAULT_SIZE, 574, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldVideo, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 654, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(textFieldRunning, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(spinnerSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(checkBoxDate))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(spinnerFontSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8)
                            .addComponent(textFieldFontColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(buttonColor)))
                    .addComponent(buttonRun))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textFieldPict, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(textFieldVideo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonOk)
                    .addComponent(buttonCancel))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void textFieldRunningKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textFieldRunningKeyReleased

    runningLabel.setRunningText(textFieldRunning.getText());
}//GEN-LAST:event_textFieldRunningKeyReleased

private void buttonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRunActionPerformed

    if (buttonRun.isSelected()) {
        runningLabel.start();
        buttonRun.setText(getLocaleMessage("dialog.stop"));
    } else {
        runningLabel.stop();
        buttonRun.setText(getLocaleMessage("dialog.start"));
    }
}//GEN-LAST:event_buttonRunActionPerformed

private void checkBoxDateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxDateActionPerformed

    runningLabel.setShowTime(checkBoxDate.isSelected());

}//GEN-LAST:event_checkBoxDateActionPerformed

private void buttonColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonColorActionPerformed

    final JDialog di = new JDialog(this, true);
    di.setTitle(getLocaleMessage("dialog.select_color"));
    final JColorChooser cc = new JColorChooser(Color.decode("#" + textFieldFontColor.getText()));
    di.setSize(450, 440);
    LayoutManager l = new FlowLayout(2, 10, 10);
    di.setLayout(l);
    di.add(cc);
    final JButton but = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            textFieldFontColor.setText(Integer.toHexString(cc.getColor().getRGB()).substring(2).toUpperCase());
            runningLabel.setForeground(Color.decode("#" + textFieldFontColor.getText()));
            di.setVisible(false);
        }
    });
    but.setText(getLocaleMessage("dialog.select"));
    but.setSize(20, 20);
    di.add(but);
    Uses.setLocation(di);
    di.setVisible(true);

}//GEN-LAST:event_buttonColorActionPerformed

private void textAreaHtmlKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textAreaHtmlKeyReleased
    runningLabel.setText(textAreaHtml.getText());
}//GEN-LAST:event_textAreaHtmlKeyReleased
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonCancel;
    private javax.swing.JButton buttonColor;
    private javax.swing.JButton buttonOk;
    private javax.swing.JToggleButton buttonRun;
    private javax.swing.JCheckBox checkBoxDate;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private ru.apertum.qsystem.common.RunningLabel runningLabel;
    private javax.swing.JSpinner spinnerFontSize;
    private javax.swing.JSpinner spinnerSpeed;
    private javax.swing.JTextArea textAreaHtml;
    private javax.swing.JTextField textFieldFontColor;
    private javax.swing.JTextField textFieldPict;
    private javax.swing.JTextField textFieldRunning;
    private javax.swing.JTextField textFieldVideo;
    // End of variables declaration//GEN-END:variables
}
